package com.gmail.cristiandeives.homingpigeon;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;

public class HomingPigeonApplication extends PreferenceActivity {
    public static final int DIALOG_INVALID_PHONE_NUMBER_ID = 0;

    public static final String ENABLED_ID = "enabled";
    public static final String PHONE_NUMBER_ID = "phone_number";
    public static final String MY_CONTACTS_ID = "my_contacts";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settings);

        Preference enabledPref = findPreference(ENABLED_ID);
        enabledPref.setOnPreferenceChangeListener(new HomingPigeonChangeListener(this));
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        Dialog dialog;

        switch (id) {
            case DIALOG_INVALID_PHONE_NUMBER_ID:
                dialog = new AlertDialog.Builder(this)
                        .setTitle(getString(R.string.dialog_invalid_phone_number_title))
                        .setMessage(getString(R.string.dialog_invalid_phone_number_message))
                        .setPositiveButton(getString(R.string.dialog_invalid_phone_number_positive), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface d, int i) {
                                d.dismiss();
                            }
                        }).create();
                break;
            default:
                dialog = null;
        }

        return dialog;
    }
}
